import { getRoleList } from "../../request/api";

let state = {
    // 角色列表数据
    roleListData: [],
}

let mutations = {
    modifyListData(state, value) {
        state.roleListData = value
    }
}

let actions = {
    // 获取角色列表数据
    getRoleListData(context) {
        getRoleList().then((res) => {
            if (res.data.code == 200) {
                context.commit("modifyListData", res.data.list)
            }
        });
    },
}

let getters = {
    roleListData(state){
        return state.roleListData
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    // 开启命名空间,防止重名
    namespaced: true
}